<link rel="stylesheet" href="../addons/jy_pingdd_pin/resource/css/style.css" />
<style type="text/css">
	i{font-style: normal;}
	.order_goods_img img {border: 1px solid rgb(215, 215, 215); border-image: none; width: 60px; height: 60px; display: block;}
	.order_goods_price i {font-size: 9px;}
	#cover{display:none;position:fixed;left:0;top:0;z-index:18888;background-color:#000000;opacity:0.7;}
	#guide{display:none;position:fixed;right:18px;top:5px;z-index:19999;}
	#guide img{width:260px;height:180px;}

	.pp_tips {padding: 10px 5px; text-align: center; font-size: 14px;}
	.pp_tips b {margin: 0px 5px; color: rgb(223, 33, 39); font-size: 18px;}

	#shareit img {max-width: 100%;}
	.mod_footer_lk a {height: 12px; color: rgb(153, 153, 153); line-height: 12px; overflow: hidden; padding-right: 8px; margin-right: 8px; border-right-color: rgb(215, 215, 215); border-right-width: 1px;
		border-right-style: solid;}
	.mod_footer_lk a:last-child {padding-right: 0px; margin-right: 0px; border-right-color: currentColor; border-right-width: 0px; border-right-style: none;}
	.address_new button {border-radius: 2px; border: 0px currentColor; border-image: none; width: 100%; height: 40px; color: rgb(255, 255, 255); line-height: 40px; font-size: 16px; margin-bottom: 10px; display: block; background-color: rgb(56, 132, 255);
	}
	.fui-tab.detail-tab {margin: 0;margin-top: 0.5rem;}

	.fui-tab.detail-tab:before {content: '';position: absolute;left: 0;top: 0;width: 200%;border-top: 1px solid #d0d0d0;display: block;
		-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scale(.5, .5);transform: scale(.5, .5);}
	.fui-tab.detail-tab:after {-webkit-transform-origin: 0 0;-ms-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);-ms-transform: scaleY(0.5);
		transform: scaleY(0.5);}
	.detail-block > div{background: #fff;padding:0.2rem;border-bottom:1px solid #f0f0f0;}
	.tab-basic img{max-width:100%;}
.fui-header:after {
	border-bottom: 0 solid #D9D9D9;
}
.step_item {width: 33.3%; padding-left: 25px; float: left; position: relative;height:1.6rem;line-height: 0.8rem;}
</style>
<div class='fui-page'>
	<div class="jy2-headertopbg">
			<div class="fui-header" style="background:none">
				<div class="fui-header-left">
					<a class="back" style="color:#fff" href="javascript:" ng-click="goback()"></a>
				</div>
				<div class="title bold" style="font-size:1rem;color:#fff">拼单详情</div>
			</div>
	 </div>
	<div class='fui-content jy2-headertop' style="padding:0.5rem;padding-bottom:1.5rem">
		<div ng-if="pagedata.goods.images.length>0" class="lynn_team_detail_head">
				<div id="carousel-container" class="carousel slide" data-role="carousel" data-param-auto="true">
					<div class="carousel-inner" role="listbox" style="height:auto;max-height:20rem;border-top-right-radius: 0.5rem;border-top-left-radius: 0.5rem;">
						<div ng-class="{'item':1,'active':$index==0}" ng-repeat="item in pagedata.goods.images">
							<a href="#">
								<img src="{{tomedia(item) || '../core/resource/images/banner-1.jpg'}}" style="display: block; width: 100%; height: 100%;">
							</a>
						</div>
					</div>
					<style>
							.fui-swipe-page .fui-swipe-bullet {background: {background}; opacity: {opacity};}
							.fui-swipe-page .fui-swipe-bullet.active {opacity: 1;}
					</style>
						<div id="carousel-jinyun" class="fui-swipe-page" style="padding: 0 5px; bottom: 10px; ">
								<div class="fui-swipe-bullet" ng-repeat="item in pagedata.goods.images" ng-class="{'active':$index==0}" data-target="#carousel-container" data-slide-to="{{$index}}"></div>
						</div>
				</div>
			<img ng-if="pagedata.team.status==1" class="team_img" src="../addons/jy_pingdd_pin/resource/images/success.png">
			<img ng-if="pagedata.team.status==0" class="team_img" src="../addons/jy_pingdd_pin/resource/images/frightin.png">
			<img ng-if="pagedata.team.status==2"  class="team_img" src="../addons/jy_pingdd_pin/resource/images/fail.png">
			<input type="hidden" name="title" value="{{pagedata.goods.title}}" id="gname">
			<h2 class="lynn_team_detail_title" style="height:auto">{{pagedata.goods.title}}</h2>
			<p class="lynn_team_detail_goods_info">
				拼单价：¥<strong>{{pagedata.goods.groupprice}}</strong>/{{pagedata.goods.unit||'件'}}
			</p>
		</div>
		<div class="pp">
			<div ng-if="pagedata.team.status==0" class="fui-cell">
				<div class="fui-cell-text c" ng-init="tool.time_down(pagedata.lasttime2)">
					<div class="subtitle light">
						<span class="starttime">
                             <span id="day">{{pagedata.lasttime2.day}}</span>
                             <span class="dw">天</span>
                             <span id="hour">{{pagedata.lasttime2.hour}}</span>
                             <span class="dw">时</span>
                             <span id="minute">{{pagedata.lasttime2.minute}}</span>
                             <span class="dw">分</span>
                             <span id="second">{{pagedata.lasttime2.second}}</span>
                        </span>
					<span>，还差<b>{{pagedata.n}}</b>人</span>
					</div>
				</div>
			</div>	
			<div style="clear: both;"></div>
			<div class="pp_users" style="padding-bottom:0">			
					<div>
						<a href="javascript:void(0);" class="pp_users_item pp_users_normal"><img ng-src="{{tomedia(pagedata.tuan_first_order.member.avatar)|| '../addons/jy_pingdd_pin/resource/avatar.png'}}"></a>				
					</div>
					<a ng-repeat="m in pagedata.orders" ng-if="m.mid!=pagedata.tuan_first_order.mid" href="javascript:void(0);" class="pp_users_item"><img src="{{m.member.avatar ||'../addons/jy_pingdd_pin/resource/images/avatar.png'}}"></a>
					<a ng-repeat="m in pagedata.lastorder" href="javascript:void(0);" class="pp_users_item"><img src="../addons/jy_pingdd_pin/resource/images/noping.png"></a>
			</div>
			<div class="pp_tips" style="padding-top:0">
				<div class="groups_info" style="font-size:0.65rem">
					{{pagedata.team.statustitle}}
				</div>
				<div ng-if="pagedata.goods.allget==1 && pagedata.myorder.pingzhong==1" class="subtitle" style="color:red">恭喜您拼中，额外获得￥{{pagedata.goods.zhong_fee || 0.00}}奖励金，已打款到您的余额！</div>
				<div ng-if="pagedata.goods.allget!=1 && pagedata.myorder.iscanyufan==1" class="subtitle" style="color:red">很遗憾没拼中，额外获得￥{{pagedata.goods.fan_price || 0.00}}奖励金补偿，已打款到您的余额！</div>
			</div>
		</div>
		<div class="fui-tab fui-tab-danger detail-tab">
			<a ng-click="pagedata.showtype='basic'" ng-class="{'active':pagedata.showtype=='basic'}">商品详情</a>
			<a ng-click="pagedata.showtype='team'" ng-class="{'active':pagedata.showtype=='team'}">拼团详情</a>
		</div>
		<div class="detail-block">
			<div ng-if="pagedata.showtype=='team'" ng-class="{'block block-team tab-team':1,'active':pagedata.showtype=='team'}" id="team">
				<div ng-repeat="order in pagedata.orders" class="lynn_team_list" ng-if="pagedata.orders.length<=3 || pagedata.lookall==1">
					<dd ng-if="order.mid==order.headsid" class="lynn_team_list_dd row" style="padding:0 0.2rem">
						<img ng-src="{{tomedia(order.member.avatar)|| '../addons/jy_pingdd_pin/custom/templates/mobile/images/avatar.png'}}" alt="{{order.nickname}}">
						<span class="fl">{{order.member.nickname}}</span>
						<span class="fr">{{order.paytime}} 开拼</span>
					</dd>
					<dd  ng-if="order.mid!=order.headsid" class="lynn_team_list_dd row" style="padding:0 0.2rem">
						<img ng-src="{{tomedia(order.member.avatar)|| '../addons/jy_pingdd_pin/custom/templates/mobile/images/avatar.png'}}" alt="{{order.nickname}}">
						<span class="fl">{{order.member.nickname||'匿名'}}</span>
						<span class="fr">{{order.paytime}} 参拼</span>
					</dd>
				</div>
				<div class="lynn_team_list_top" ng-click="pagedata.lookall=1" ng-if="pagedata.orders.length>3">
						<p style="background:none">查看更多全部团详情 <i class="iconfont icon lynn_icon">&#xe764;</i></p>
				</div>
			</div>
			<div ng-if="pagedata.showtype=='basic'" ng-class="{'block block-team tab-basic':1,'active':pagedata.showtype=='basic'}" style="display: block;">
				<div ng-if="pagedata.goods.content" class="lynn_goods_content_info content-images" ng-bind-html="trust(pagedata.goods.content)">
				</div>
				<div ng-if="pagedata.groupsset.groups_description" class="lynn_goods_content_info content-images" ng-bind-html="trust(pagedata.groupsset.groups_description)">
				</div>
				<div ng-if="!pagedata.goods.content" class="lynn_goods_content_info content-images" ng-bind-html="trust(pagedata.goods.description)">
				</div>
				<div ng-if="!pagedata.groupsset.description && !pagedata.goods.content" style="font-size:0.7rem;padding:0.2rem">暂无商品详情</div>
			</div>
		</div>
		<div class="step">
			<div class="step_hd">
				<i class="left"></i>拼单玩法<a class="step_more" href="javascript:;" ng-click="pagedata.showrules=true">查看详情></a>
			</div>
			<div id="footItem" class="step_list">
				<div class="step_item">
					<div class="step_num">1</div>
					<div class="step_detail">
						<p class="step_tit">参与拼团有奖励，
							<br><span class="red">{{pagedata.goods.teamnum ||0}}</span>人成团</p>
					</div>
				</div>
				<div ng-class="{'step_item':1,'':pagedata.n>0 || pagedata.team.status==1}">
					<div class="step_num">2</div>
					<div ng-if="pagedata.goods.allget!=1" class="step_detail">
						<p class="step_tit"><span class="red">{{pagedata.goods.lastnum ||0}}</span>人拼中发货
							<br><span class="red">{{pagedata.goods.failnum ||0}}</span>人未中退款</p>
					</div>
					<div ng-if="pagedata.goods.allget==1" class="step_detail">
						<p class="step_tit"><span class="red">{{pagedata.goods.lastnum ||0}}</span>人拼中，获得
							<br><span class="red">{{pagedata.goods.zhong_fee ||0}}</span>元奖励和商品</p>
					</div>
				</div>
				<div ng-class="{'step_item':1,'':pagedata.n>0 || pagedata.team.status==1}" id="step_3">
					<div class="step_num">3</div>
					<div ng-if="pagedata.goods.allget!=1" class="step_detail">
						<p class="step_tit" ><span class="red">{{pagedata.goods.failnum ||0}}</span>人未拼中补贴
							<br><span class="red">{{pagedata.goods.fan_price || '0.00'}}</span>元红包补贴</p>
					</div>
					<div ng-if="pagedata.goods.allget==1" class="step_detail">
						<p class="step_tit" ><span class="red">{{pagedata.goods.failnum ||0}}</span>人未拼中，获得
							<br><span class="red">{{pagedata.goods.fan_price || '0.00'}}</span>元奖励和商品</p>
					</div>
				</div>
			</div>
		</div>
		<div style="height:2.5rem;"></div>
	</div>
	<div class="fui-navbar lynn_footer">		
			<a ng-if="pagedata.team.status>1" class="other" href="javascript:void(0);">
				<p class="">{{pagedata.team.statustitle}}</p>
			</a>
			<a ng-if="pagedata.team.status==1" class="other" href="javascript:void(0);" ng-click="access_json('jy_weishop/order.detail//id='+pagedata.myorder.orderid)">
				<p class="">{{pagedata.team.statustitle}}</p>
			</a>
			<a ng-if="pagedata.team.status==0 && pagedata.myorder.id" class="other" ng-click="pagedata.open();" href="javascript:void(0);">
					<p class="">快邀请好友拼单吧</p>
			</a>
			<a ng-if="pagedata.gobuy==1 && pagedata.team.status==0 && !pagedata.myorder.id" class="other" href="javascript:;" ng-click="pagedata.check_buy('',pagedata.team.id)">
					<p class="">我要拼单</p>
			</a>
			<a ng-if="pagedata.gobuy==2 && pagedata.team.status==0 && !pagedata.myorder.id" class="other" href="javascript:;" onclick="$('#showspec').modal();">
					<p class="">我要拼单</p>
			</a>
			<a ng-if="pagedata.team.status==2 && pagedata.myorder.status==2"" class="other" href="javascript:void(0);">
				<p class="">本次拼单已过期</p>
			</a>
		<a class="home" href="javascript:;" ng-click="access_json('jy_pingdd_pin/index/')">
			<p class="icon icon-shouye" style="margin-bottom:0"></p>
			首页
		</a>
	</div>
	<div id="cover"></div>
	<div id="guide"><img src="../addons/jy_pingdd_pin/resource/images/guide1.png"></div>
</div>
<div id="showspec" class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
<div class="modal-dialog" style="width:100%;left:0;bottom:0">
<div class="modal-content" ng-include="sys_html('goods/picker')"></div>
</div>
</div>
<div ng-if="pagedata.showrules" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<i class="closed icon icon-cuowu" style="font-size:1.2rem;top:105%;" ng-click="pagedata.showrules=false"></i>
			<div class="content-images" style="padding:0.5rem;height:20rem; overflow-y:scroll;">
					<div class="title bold" style="font-size:0.8rem">拼单规则 / <small>Read Rule</small></div>
					<div class="text" style="padding-top:0.5rem;font-size:0.7rem" ng-bind-html="trust(pagedata.pluginset.rules)">
					</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	require(['bootstrap', 'hammer'], function($, Hammer){
		$('#carousel-container').carousel();
		var mc = new Hammer($('#carousel-container').get(0));
		mc.on("panleft", function(ev) {
			$('#carousel-container').carousel('next');
		});
		mc.on("panright", function(ev) {
			$('#carousel-container').carousel('prev');
		});
	});
	scope.pagedata.open=function(){
			$("#cover").show();
			$("#guide").show();
	}
	$(function(){
		$("#invitation").on("click",function(){
			if($("#cover").css("display")=='none'){
				$("#cover").show();
				$("#guide").show();
			}
		})
		$("#cover").on("click",function(){
			$("#cover").hide();
			$("#guide").hide();
		})
	})
//减少
scope.pagedata.showtype='basic';
scope.pagedata.minus=function(){
	if(scope.pagedata.post.num <=1){
		return false;
	}
	scope.pagedata.post.num--;
	scope.$evalAsync();
}
//增加
scope.pagedata.plus=function(){
	if(parseInt(scope.pagedata.goods.usermaxbuy)>0 && parseInt(scope.pagedata.goods.order_goodscount) + parseInt(scope.pagedata.post.num)>=parseInt(scope.pagedata.goods.usermaxbuy)){
		scope.message('不能再加了，你已购买'+scope.pagedata.goods.order_goodscount+'件，超过该商品最大购买量'+scope.pagedata.goods.usermaxbuy+'！','error');
		return false;
	}
	if(parseInt(scope.pagedata.goods.maxbuy)>0 && parseInt(scope.pagedata.post.num)>=parseInt(scope.pagedata.goods.maxbuy)){
		scope.message('不能再加了，超过该商品单次购买'+scope.pagedata.goods.maxbuy+'量！','error');
		return false;
	}
	if(parseInt(scope.pagedata.post.num)>=parseInt(scope.pagedata.options.stock)){
		scope.message('不能再加了，超了库存'+scope.pagedata.options.stock+'啦！','error');
		return false;
	}
	scope.pagedata.post.num++;
	scope.$evalAsync();
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.post.specid;
		specid = specid.join('_');
	scope.post_json('jy_pingdd_pin/goods.detail/get_optionsid/',{'specid':specid,'goodsid':scope.pagedata.goods.id},function(res){
			console.log(specid);
			scope.pagedata.post.optionsid=res.options.id;
			scope.pagedata.options=res.options;
			scope.pagedata.goods.price=res.options.price;
			scope.pagedata.goods.image=res.options.thumb?res.options.thumb:scope.pagedata.goods.image;
			scope.pagedata.goods.originalprice=res.options.productprice;
			scope.pagedata.selespename=res.selespename;
			scope.$evalAsync();
	});
}
scope.pagedata.check_buy=function(e,teamid){
	var goodsid=scope.pagedata.post.goodsid
	var num=scope.pagedata.post.num
	var optionsid=scope.pagedata.post.optionsid
	var addressid=scope.pagedata.post.addressid
	var storeid=scope.pagedata.post.storeid
	var single=e?1:0;
	teamid=teamid?teamid:0;
	scope.get('jy_pingdd_pin/goods.detail/check_buy/teamid='+teamid+'&single='+single+'&goodsid='+goodsid+'&num='+num+'&optionsid='+optionsid+'&addressid='+addressid+'&storeid='+storeid,function(res){});
}
</script>